<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- 编制材料复试月报 -->
    <div id="base-breadcrumb" style="position: relative; overflow: hidden">
      <!-- 搜索 -->
      <searchData :searchData="searchArr" @search="search"></searchData>
      <!-- 表格 -->
      <a-card :bordered="false">
        <!-- <title-name :title="$route.meta.title"></title-name> -->
        <!-- 表格 -->
        <service-export-mould
            v-btnPermission="[
                      {
                        ident: 'prma_seex',
                        code: 'seex_qm_052_expco_01'
                      },
                      {
                        ident: 'prma_buco',
                        code: 'buco_qm_052_expco_01'
                      }
              ]"
            class="ml12"
            :serviceiUrl="qualityApiUrl"
            icon="cloud-download"
            url="/quality/month/experiment/completed/excel"
            buttonText="导出竣工项目材料复试月报"
          ></service-export-mould>
        <a-tabs v-model="orgLevel" :animated="false">
          <a-tab-pane v-for="item in tabs" :key="item.id" :tab="item.name">
            <Table :ref="'table' + item.id" :key="item.id" :api="api" :orgLevel="orgLevel" />
          </a-tab-pane>
        </a-tabs>
      </a-card>
    </div>
  </base-breadcrumb>
</template>

<script>
import { monthExperiment } from '@/api/quality/quality' // api
import BasePage from '@/views/basePage'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目名称
import OrgTreeSelect from '@/components/OrgTreeSelect'
import Table from './components/Table' // 表格
import ServiceExportMould from '@/components/ServiceExportMould'
import { qualityApiUrl } from '@/api/config.js'

const searchArr = [
  // 搜索框
  {
    name: '所属单位',
    valueKey: 'searchQuery',
    type: OrgTreeSelect,
  },
  // {
  //   name: '所属分公司',
  //   type: SelectSubCompany,
  //   valueKey: 'branchComId'
  // },
  // {
  //   name: '所属项目',
  //   type: SelectProject,
  //   keyValue: 'branchComId',
  //   valueKey: 'projectId'
  // },
  {
    name: '月报时间',
    type: 'monthRange',
    value: 'month',
    attr: {
      rangeFormat: ['startDate', 'endDate'],
      placeholder: ['开始时间', '截止时间']
    }
  }
]

export default {
  name: 'a' + Date.now(),
  extends: new BasePage(),
  components: {
    Table,
    ServiceExportMould
  },
  data() {
    this.searchArr = searchArr
    return {
      qualityApiUrl,
      api: monthExperiment, // 汇总api
      tabs: [
        {
          id: 2,
          name: '公司'
        },
        {
          id: 1,
          name: '分公司'
        },
        {
          id: 0,
          name: '项目部'
        }
      ],
      orgLevel: 2 // 组织层级
    }
  },
  methods: {
    // 搜索
    search(value) {
      console.log(this.$refs)
      this.$refs['table' + this.orgLevel][0].search(value)
    },
    // 操作栏
    handleManage(type, record) {}
  }
}
</script>
